package singleton.lazy;

/**
 * @author Feng
 * @date 2019/3/10 15:42
 */
public class LazyInnerClassSingleton {
    private LazyInnerClassSingleton(){
        if(LazyHolder.LAZY != null){
            throw new RuntimeException("不允许创建多个实例");
        }
    }

    public static final LazyInnerClassSingleton getInstance(){
        LazyInnerClassSingleton lazyInnerClassSingleton = LazyHolder.LAZY;
        return lazyInnerClassSingleton;
    }

    private static class LazyHolder{
        private static final LazyInnerClassSingleton LAZY = new LazyInnerClassSingleton();
    }
}
